home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / network / usrpr103.zip / NWADDR.C < prev    next >
C/C++ Source or Header  |  1992-06-24  |  1KB  |  62 lines

  1.  
  2. //    NWADDR.C
  3. //    Netware Address - Asks the IPX for the hardware address of our card
  4. //        returns a 0 if ipx is not loaded.
  5.  
  6. #include <dos.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. int        get_ipx_spx_pointer (void) ;// gets ipx address
  11. void far    (*ipx_spx)(void) ;        // far pointer to ipx functions
  12. struct reply_buffer {
  13.     unsigned char    network_number[4] ;
  14.     unsigned char    node_address[6] ;
  15. } myRB ;
  16.  
  17. void NW_getaddr( struct reply_buffer *vRB ){
  18.  
  19.     _BX = 0x09 ;
  20.     _ES = FP_SEG (vRB) ;
  21.     _SI = FP_OFF (vRB) ;
  22.     ipx_spx () ;
  23. }
  24.  
  25.  
  26. int check_nwaddr( char *s )
  27. {
  28.   int     i ;
  29.   char Hex[] = "0123456789ABCDEF";        // Hex conversion array
  30.  
  31.  
  32.     if (get_ipx_spx_pointer()) { //IPX Driver is not installed!
  33.         strcpy("NONE:",s);
  34.         return 0;
  35.     }
  36.  
  37.  
  38.     NW_getaddr( &myRB );
  39.  
  40.     for (i=0; i<6; i++){
  41.         *s++ = Hex[( myRB.node_address[i] & 0xf0 ) >> 4 ];
  42.         *s++ = Hex[ myRB.node_address[i] & 0x0f ];
  43.         if (i < 5) *s++ = ':';
  44.     }
  45.  
  46.     return (1) ;
  47. }
  48.  
  49.  
  50. int    get_ipx_spx_pointer (void)
  51. {
  52. union REGS     regs ;
  53. struct SREGS    sregs ;
  54.  
  55.     regs.x.ax = 0x7a00 ;
  56.     int86x (0x2f, ®s, ®s, &sregs) ;
  57.     if (regs.h.al != 0xff)
  58.         return -1 ;
  59.  
  60.     ipx_spx = (void (far *)()) MK_FP (sregs.es, regs.x.di) ;
  61.     return 0 ;
  62. }